require([
  "jquery",
  "ko",
  "bootstrap",
  "jquery-select2",
  "jquery-slimscroll",
  "jquery-gritter",
  "jquery-blockui",
  "bootstrap-datepicker",
  "bootstrap-datetimepickerlocal",
  "akcy"
], function($, ko) {
  var akcy = arguments[arguments.length - 1];
  akcy.ui.init();
  var unitList = akcy.tree().options({dataQueryUrl: 'config/UnitInfoList'}).optionsExtend({
    appId: "monitor",
    searched: function(data) {},
    nodeClicked: function(data, e) {
      laterallineInfo.getInstance().reset();
      table.getInstance().unitId(data.unitId);
      table.getInstance().unitName(data.unitAlias);
      table.load();
      e.stopPropagation();
    }
  }).bind("UnitInfo").load();

  var table = akcy.table().options({
    fields: [
      {
        field: 'unitId',
        value: ko.observable(0)
      }
    ],
    headers: [
      {
        text: '装置名称',

        width: '10%'
      }, {
        text: '侧线名称',

        width: '11%'
      }, {
        text: '计量公式',

        width: '5%'
      }
    ],
    // defaultOrderBy: "U_ID",
    dataQueryUrl: 'config/SideLineInfoList'
  }).optionsExtend({
    appId: "monitor",
    unitName: ko.observable(),
    rowclick: function(data) {
      laterallineInfo.getInstance().reset();
      laterallineInfo.load(data);
    }
  }).bind("laterallineList").load();
  var laterallineInfo = akcy.form().options({
    fields: [
      {
        field: 'nodeId',
        value: ko.observable()
      }, {
        field: 'unitName',
        value: ko.observable()
      }, {
        field: 'slineName',
        value: ko.observable()
      }, {
        field: 'formula',
        value: ko.observable()
      }, {
        field: 'areaForm',
        value: ko.observable()
      }, {
        field: 'groupId',
        value: ko.observable()
      }, {
        field: 'isRvs',
        value: ko.observable()
      }, {
        field: 'refSidelineId',
        value: ko.observable()
      }, {
        field: 'rsid',
        value: ko.observable()
      }, {
        field: 'slineInoutTypeId',
        value: ko.observable()
      }, {
        field: 'unitId',
        value: ko.observable()
      }, {
        field: 'slineMtrlTypeId',
        value: ko.observable()
      }
    ],
    dataUpdateUrl: 'config/ModifySideLineInfo'
  }).optionsExtend({
    appId: 'monitor',
    updated: function() {
      table.load();
      akcy.alert.success("保存成功！");
    }
  }).bind("laterallineInfo");

});
